﻿
using Logistics.Model;
using SAP.Middleware.Connector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Logistics.DataAccess
{
    public class SAP_Data
    {
        private readonly TC_OWI_FILE _tc_OWI_FILE;
        private List<Model.TC_OWI_FILE> TC_OWIDatas;
        private readonly OWR_FILE _OWR_FILE;
        private List<Model.OWR_FILE> OWRDatas;

    //    private SAP_Data sapData = new SAP_Data();

        public SAP_Data()
        {
            TC_OWIDatas = new List<Model.TC_OWI_FILE>();
            _tc_OWI_FILE = new TC_OWI_FILE();
            TC_OWIDatas = _tc_OWI_FILE.GetList();

            OWRDatas = new List<Model.OWR_FILE>();
            _OWR_FILE = new OWR_FILE();
            OWRDatas = _OWR_FILE.GetList();
        }

        #region 查询SAP数据
        /// <summary>
        /// 转储订单
        /// </summary>
        public List<Model.SAPDataModel> GetPomigoInfo(string zpointf)
        {
            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
            RfcRepository SapRfcRepository = SapRfcDestination.Repository;
            var list = new List<Model.SAPDataModel>();

            //转储订单
            IRfcFunction myfun = SapRfcRepository.CreateFunction("ZMMRFC_POMIGO");
            //传入结构INPUT  
            myfun.SetValue("ZPOINTF", "PSUB0" + zpointf);
            //myfun.SetValue("ZPOINTF", "PSUB01");
            myfun.SetValue("CALL_TYPE", "Q");
            myfun.Invoke(SapRfcDestination);
            IRfcTable IrfTable = myfun.GetTable("IT_ZTMM009K");
            IRfcTable IrfTable_tc_ows = myfun.GetTable("IT_ZTMM009P");

            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable.Count; i++)
            {
                IrfTable.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                model.l_type = "转储订单";
                if (zpointf == "1")
                    model.l_tc_owr001 = "14";
                if (zpointf == "2")
                    model.l_tc_owr001 = "24";
                model.l_tc_owr002 = IrfTable.GetString("EBELN");
                model.l_tc_owr003 = IrfTable.GetString("Bukrs");
                model.l_tc_owr004 = "";
                model.l_tc_owr005 = IrfTable.GetString("Bukrs");
                var bedat = IrfTable.GetString("Bedat");
                model.l_tc_owr006 = Convert.ToDateTime(bedat);
                model.l_tc_owr007 = null;
                model.l_tc_owr008 = null;
                var lifnr = IrfTable.GetString("Lifnr");
                if (!string.IsNullOrWhiteSpace(lifnr))
                {
                    model.l_tc_owr009 = TC_OWIDatas.FirstOrDefault(m => m.TC_OWI008 == lifnr)?.TC_OWI001;
                }
                else
                {
                    model.l_tc_owr009 = lifnr;
                }
                var lifn2 = IrfTable.GetString("Lifn2");
                if (!string.IsNullOrWhiteSpace(lifn2))
                {
                    model.l_tc_owr010 = TC_OWIDatas.FirstOrDefault(m => m.TC_OWI008 == lifn2)?.TC_OWI001;
                }
                else
                {
                    model.l_tc_owr010 = lifn2;
                }
                model.l_tc_owr011 = "N";
                model.l_tc_owr012 = "N";
                model.l_tc_owr015 = IrfTable.GetString("Bukrs");
                model.l_tc_owr016 = IrfTable.GetString("Zzmem");
                model.l_tc_owr019 = "1";
                model.l_tc_owr024 = DateTime.Now;
                model.l_tc_owr025 = "1";
                model.l_tc_owr026 = IrfTable.GetString("Zpointf");
                model.l_tc_owr027 = "N";
                //  var KDara_w = new ZTMM009K();
                //成功就回写
                model.ZTMM009K_Mandt = IrfTable.GetString("Mandt");
                model.ZTMM009K_Ebeln = IrfTable.GetString("Ebeln");
                model.ZTMM009K_Ekorg = IrfTable.GetString("Ekorg");
                model.ZTMM009K_Bsart = IrfTable.GetString("Bsart");
                model.ZTMM009K_Lifnr = IrfTable.GetString("Lifnr");
                model.ZTMM009K_Lifn2 = IrfTable.GetString("Lifn2");
                model.ZTMM009K_Bedat = IrfTable.GetString("Bedat");
                model.ZTMM009K_Call_Type = IrfTable.GetString("Call_Type");
                model.ZTMM009K_Zpointf = IrfTable.GetString("Zpointf");
                list.Add(model);
            }
            //return list;



            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable_tc_ows.Count; i++)
            {
                IrfTable_tc_ows.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                if (zpointf == "1")
                    model.l_tc_ows000 = "14";
                if (zpointf == "2")
                    model.l_tc_ows000 = "24";
                model.l_tc_ows001 = IrfTable_tc_ows.GetString("Ebeln");
                model.l_tc_ows002 = Convert.ToString(Convert.ToInt32(IrfTable_tc_ows.GetString("Ebelp")));
                model.l_tc_ows003 = IrfTable_tc_ows.GetString("Lgort");
                model.l_tc_ows004 = "";
                model.l_tc_ows005 = IrfTable_tc_ows.GetString("Matnr");
                model.l_tc_ows006 = IrfTable_tc_ows.GetString("Meins");
                model.l_tc_ows007 = IrfTable_tc_ows.GetString("Menge");
                model.l_tc_ows008 = "";
                model.l_tc_ows009 = "";
                model.l_tc_ows010 = "";
                model.l_tc_ows011 = "";
                model.l_tc_ows012 = "";
                model.l_tc_ows013 = "";
                model.l_tc_ows014 = "";
                model.l_tc_ows019 = null;
                model.l_tc_ows022 = IrfTable_tc_ows.GetString("Charg");
                model.l_outdt = Convert.ToDateTime(IrfTable_tc_ows.GetString("OUTDT"));

                model.ZTMM009P_Mandt = IrfTable_tc_ows.GetString("Mandt");
                model.ZTMM009P_Ebeln = IrfTable_tc_ows.GetString("Ebeln");
                model.ZTMM009P_Ebelp = IrfTable_tc_ows.GetString("Ebelp");
                model.ZTMM009P_Matnr = IrfTable_tc_ows.GetString("Matnr");
                model.ZTMM009P_Menge = IrfTable_tc_ows.GetString("Menge");
                model.ZTMM009P_Meins = IrfTable_tc_ows.GetString("Meins");
                model.ZTMM009P_Charg = IrfTable_tc_ows.GetString("Charg");
                model.ZTMM009P_Werks = IrfTable_tc_ows.GetString("Werks");
                model.ZTMM009P_Lgort = IrfTable_tc_ows.GetString("Lgort");
                model.ZTMM009P_Bwart = IrfTable_tc_ows.GetString("Bwart");
                model.ZTMM009P_Outdt = IrfTable_tc_ows.GetString("Outdt");
                model.ZTMM009P_Call_Type = IrfTable_tc_ows.GetString("Call_Type");
                model.ZTMM009P_Zpointf = IrfTable_tc_ows.GetString("Zpointf");

                list.Add(model);
            }
            return list;
        }

        /// <summary>
        /// 物料凭证
        /// </summary>
        public List<Model.SAPDataModel> GetRkpfExport()
        {
            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
            RfcRepository SapRfcRepository = SapRfcDestination.Repository;
            var list = new List<Model.SAPDataModel>();
            //物料凭证
            IRfcFunction myfun = SapRfcRepository.CreateFunction("ZMMRFC_RKPF_EXPORT");
            //传入参数
            myfun.SetValue("CALL_TYPE", "Q");
            myfun.SetValue("ZPSINTF", "PSRE01");
            myfun.Invoke(SapRfcDestination);
            IRfcTable IrfTable = myfun.GetTable("EX_TAB");

            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable.Count; i++)
            {
                IrfTable.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                model.l_type = "物料凭证";
                var bwart = IrfTable.GetString("Bwart");
                if (!string.IsNullOrWhiteSpace(bwart))
                {
                    model.l_tc_owr001 = OWRDatas.FirstOrDefault(m => m.OWR001 == bwart)?.OWR002;
                }
                model.l_tc_owr002 = IrfTable.GetString("Rsnum");
                model.l_tc_owr003 = IrfTable.GetString("Werks");
                model.l_tc_owr004 = IrfTable.GetString("Werks");
                model.l_tc_owr005 = "";
                var rsdat = IrfTable.GetString("Rsdat");
                model.l_tc_owr006 = Convert.ToDateTime(rsdat);
                model.l_tc_owr007 = null;
                model.l_tc_owr008 = null;
                var zcss = IrfTable.GetString("Zcss");
                if (!string.IsNullOrWhiteSpace(zcss))
                {
                    model.l_tc_owr009 = TC_OWIDatas.FirstOrDefault(m => m.TC_OWI008 == zcss)?.TC_OWI001;
                }
                else
                {
                    model.l_tc_owr009 = zcss;
                }

                model.l_tc_owr010 = "";
                model.l_tc_owr016 = "";
                model.l_tc_owr011 = "N";
                model.l_tc_owr012 = "N";
                model.l_tc_owr019 = "1";
                model.l_tc_owr024 = DateTime.Now;
                model.l_tc_owr025 = "2";
                model.l_tc_owr026 = IrfTable.GetString("Bwart");
                model.l_tc_owr027 = "N";

                model.l_tc_ows000 = model.l_tc_owr001;
                model.l_tc_ows001 = model.l_tc_owr002;
                model.l_tc_ows002 = IrfTable.GetString("Rspos");
                model.l_tc_ows003 = IrfTable.GetString("Lgort");
                model.l_tc_ows005 = IrfTable.GetString("Matnr");
                model.l_tc_ows006 = IrfTable.GetString("Meins");
                model.l_tc_ows007 = IrfTable.GetString("Bdmng");
                model.l_tc_ows014 = "0";
                model.l_tc_ows022 = IrfTable.GetString("Charg");


                //成功就回写
                model.ZSMMRFC_PKPF_EXPORT_Bwart = IrfTable.GetString("Bwart");
                model.ZSMMRFC_PKPF_EXPORT_Rsdat = IrfTable.GetString("Rsdat");
                model.ZSMMRFC_PKPF_EXPORT_Werks = IrfTable.GetString("Werks");
                model.ZSMMRFC_PKPF_EXPORT_Rsnum = IrfTable.GetString("Rsnum");
                model.ZSMMRFC_PKPF_EXPORT_Rspos = IrfTable.GetString("Rspos");
                model.ZSMMRFC_PKPF_EXPORT_Matnr = IrfTable.GetString("Matnr");
                model.ZSMMRFC_PKPF_EXPORT_Zcss = IrfTable.GetString("Zcss");
           

                list.Add(model);
            }
            return list;
        }

        /// <summary>
        /// 预留凭证
        /// </summary>
        public List<Model.SAPDataModel> GetMsegExport()
        {
            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
            RfcRepository SapRfcRepository = SapRfcDestination.Repository;
            var list = new List<Model.SAPDataModel>();
            //预留凭证
            IRfcFunction myfun = SapRfcRepository.CreateFunction("ZMMRFC_MSEG_EXPORT");
            myfun.SetValue("CALL_TYPE", "Q");
            myfun.Invoke(SapRfcDestination);
            IRfcTable IrfTable = myfun.GetTable("MSEG_TAB");

            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable.Count; i++)
            {
                IrfTable.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                model.l_type = "预留凭证";
                var bwart = IrfTable.GetString("Bwart");
                if (!string.IsNullOrWhiteSpace(bwart))
                {
                    model.l_tc_owr001 = OWRDatas.FirstOrDefault(m => m.OWR001 == bwart)?.OWR002;
                }
                model.l_tc_owr002 = IrfTable.GetString("Mblnr");
                model.l_tc_owr003 = IrfTable.GetString("Werks");
                model.l_tc_owr004 = IrfTable.GetString("Werks");
                model.l_tc_owr005 = IrfTable.GetString("Werks");
                var cpudt = IrfTable.GetString("Cpudt");
                model.l_tc_owr006 = Convert.ToDateTime(cpudt);
                model.l_tc_owr007 = null;
                model.l_tc_owr008 = null;
                model.l_tc_owr009 = "WX20C";
                model.l_tc_owr010 = "";
                model.l_tc_owr016 = "";
                model.l_tc_owr011 = "N";
                model.l_tc_owr012 = "N";
                model.l_tc_owr019 = "1";
                model.l_tc_owr024 = DateTime.Now;
                model.l_tc_owr025 = "3";
                model.l_tc_owr026 = IrfTable.GetString("Bwart");
                model.l_tc_owr027 = "N";

                model.l_tc_ows000 = model.l_tc_owr001;
                model.l_tc_ows001 = model.l_tc_owr002;
                model.l_tc_ows002 = IrfTable.GetString("Zeile");
                model.l_tc_ows003 = IrfTable.GetString("Lgort");
                model.l_tc_ows005 = IrfTable.GetString("Matnr");
                model.l_tc_ows006 = IrfTable.GetString("Meins");
                model.l_tc_ows007 = IrfTable.GetString("Lfimg");
                model.l_tc_ows014 = "0";
                model.l_tc_ows022 = IrfTable.GetString("Charg");
                //成功就回写
                model.ZMMRFC_MSEG_EXPORT_Budat = IrfTable.GetString("Budat");
                model.ZMMRFC_MSEG_EXPORT_Cpudt = IrfTable.GetString("Cpudt");
                model.ZMMRFC_MSEG_EXPORT_Xblnr = IrfTable.GetString("Xblnr");
                model.ZMMRFC_MSEG_EXPORT_Usnam = IrfTable.GetString("Usnam");
                model.ZMMRFC_MSEG_EXPORT_Mblnr = IrfTable.GetString("Mblnr");
                model.ZMMRFC_MSEG_EXPORT_Mjahr = IrfTable.GetString("Mjahr");
                model.ZMMRFC_MSEG_EXPORT_Zeile = IrfTable.GetString("Zeile");
                model.ZMMRFC_MSEG_EXPORT_Bwart = IrfTable.GetString("Bwart");
                model.ZMMRFC_MSEG_EXPORT_Matnr = IrfTable.GetString("Matnr");
                model.ZMMRFC_MSEG_EXPORT_Lfimg = Convert.ToDecimal(IrfTable.GetString("Lfimg"));
                model.ZMMRFC_MSEG_EXPORT_Meins = IrfTable.GetString("Meins");
                model.ZMMRFC_MSEG_EXPORT_Charg = IrfTable.GetString("Charg");
                model.ZMMRFC_MSEG_EXPORT_Werks = IrfTable.GetString("Werks");
                model.ZMMRFC_MSEG_EXPORT_Lgort = IrfTable.GetString("Lgort");
                model.ZMMRFC_MSEG_EXPORT_Kostl = IrfTable.GetString("Kostl");
   

                list.Add(model);
            }
            return list;
        }



        /// <summary>
        /// 交货单
        /// </summary>
        public List<Model.SAPDataModel> GetDelivery()
        {
            RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
            RfcRepository SapRfcRepository = SapRfcDestination.Repository;
            var list = new List<Model.SAPDataModel>();
            //交货单
            IRfcFunction myfun = SapRfcRepository.CreateFunction("ZSDRFC_DELIVERY");
            //传入参数
            myfun.SetValue("DELIVERY_NOTE", "");
            myfun.SetValue("ZEDITP", "");
            myfun.SetValue("CALL_TYPE", "Q");
            myfun.Invoke(SapRfcDestination);
            IRfcTable IrfTable = myfun.GetTable("IT_ZTSD001K");
            IRfcTable IrfTable_tc_ows = myfun.GetTable("IT_ZTSD001P");
            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable.Count; i++)
            {
                IrfTable.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                model.l_type = "交货单";
                var Inftid = IrfTable.GetString("Inftid");
                if (!string.IsNullOrWhiteSpace(Inftid))
                {
                    model.l_tc_owr001 = OWRDatas.FirstOrDefault(m => m.OWR001 == Inftid)?.OWR002;
                }
                model.l_tc_owr002 = IrfTable.GetString("Vbeln");
                model.l_tc_owr003 = IrfTable.GetString("Vkorg");
                model.l_tc_owr004 = "";
                model.l_tc_owr005 = IrfTable.GetString("Kunag");
                var erdat = IrfTable.GetString("Erdat");
                model.l_tc_owr006 = Convert.ToDateTime(erdat);

                var vdatu = IrfTable.GetString("Vdatu");
                if (vdatu.ToString() == "0000-00-00")
                    model.l_tc_owr007 = null;
                else
                    model.l_tc_owr007 = Convert.ToDateTime(vdatu);

                var mahdt = IrfTable.GetString("Mahdt");
                if (mahdt.ToString() == "0000-00-00")
                    model.l_tc_owr008 = null;
                else
                    model.l_tc_owr008 = Convert.ToDateTime(mahdt);

                var lifnr1 = IrfTable.GetString("Lifnr1");
                if (!string.IsNullOrWhiteSpace(lifnr1))
                {
                    model.l_tc_owr009 = TC_OWIDatas.FirstOrDefault(m => m.TC_OWI008 == lifnr1)?.TC_OWI001;
                }
                else
                {
                    model.l_tc_owr009 = lifnr1;
                }
                var lifn2 = IrfTable.GetString("Lifnr2");
                if (!string.IsNullOrWhiteSpace(lifn2))
                {
                    model.l_tc_owr010 = TC_OWIDatas.FirstOrDefault(m => m.TC_OWI008 == lifn2)?.TC_OWI001;
                }
                else
                {
                    model.l_tc_owr010 = lifn2;
                }
                model.l_tc_owr011 = "N";
                model.l_tc_owr012 = "N";
                model.l_tc_owr013 = IrfTable.GetString("Bstkd");
                model.l_tc_owr014 = IrfTable.GetString("Ernam");
                model.l_tc_owr015 = IrfTable.GetString("Kunnr");
                model.l_tc_owr016 = IrfTable.GetString("Memo1");
                model.l_tc_owr017 = IrfTable.GetString("Memo2");
                model.l_tc_owr018 = IrfTable.GetString("Memo3");
                model.l_tc_owr019 = "1";
                model.l_tc_owr024 = DateTime.Now;
                model.l_tc_owr025 = "4";
                model.l_tc_owr026 = IrfTable.GetString("Inftid");
                model.l_tc_owr027 = "N";
                model.l_tc_owr0132 = IrfTable.GetString("Zylzd1");
                model.l_tc_owr0131 = IrfTable.GetString("Zylzd2");

                model.l_tc_oww000 = model.l_tc_owr001;
                model.l_tc_oww001 = model.l_tc_owr002;
                model.l_tc_oww002 = "1";
                model.l_tc_oww003 = "商业折扣";
                model.l_tc_oww004 = IrfTable.GetString("Netwr1");

                //成功就回写
                model.ZTSD001K_Mandt = IrfTable.GetString("Mandt");
                model.ZTSD001K_Inftid = IrfTable.GetString("Inftid");
                model.ZTSD001K_Vbeln = IrfTable.GetString("Vbeln");
                model.ZTSD001K_Kunag = IrfTable.GetString("Kunag");
                model.ZTSD001K_Lifnr1 = IrfTable.GetString("Lifnr1");
                model.ZTSD001K_Lifnr2 = IrfTable.GetString("Lifnr2");
                model.ZTSD001K_Z_Status = IrfTable.GetString("Z_Status");
                list.Add(model);
            }
            // return list;
            //循环把IRfcTable里面的数据放入Table里面，因为类型不同，不可直接使用。             
            for (int i = 0; i < IrfTable_tc_ows.Count; i++)
            {
                IrfTable_tc_ows.CurrentIndex = i;
                var model = new Model.SAPDataModel();
                model.l_tc_ows001 = IrfTable_tc_ows.GetString("Vbeln");
                model.l_tc_ows002 = Convert.ToString(Convert.ToInt32(IrfTable_tc_ows.GetString("Posnr")));
                model.l_tc_ows003 = IrfTable_tc_ows.GetString("Lgort");
                model.l_tc_ows004 = IrfTable_tc_ows.GetString("Pstyv");
                model.l_tc_ows005 = IrfTable_tc_ows.GetString("Matnr");
                model.l_tc_ows006 = IrfTable_tc_ows.GetString("Vrkme");
                model.l_tc_ows007 = IrfTable_tc_ows.GetString("Lfimg");
                model.l_tc_ows008 = IrfTable_tc_ows.GetString("Netpr");
                model.l_tc_ows009 = IrfTable_tc_ows.GetString("Netwr2");
                model.l_tc_ows010 = IrfTable_tc_ows.GetString("Netwr3");
                model.l_tc_ows011 = IrfTable_tc_ows.GetString("Netwr4");
                model.l_tc_ows012 = IrfTable_tc_ows.GetString("Kdmat");
                model.l_tc_ows013 = "";
                model.l_tc_ows014 = "0";
                model.l_tc_ows019 = null;
                model.l_tc_ows022 = IrfTable_tc_ows.GetString("Charg");


                model.ZTSD001P_Mandt = IrfTable_tc_ows.GetString("Mandt");
                model.ZTSD001P_Vbeln = IrfTable_tc_ows.GetString("Vbeln");
                model.ZTSD001P_Posnr = Convert.ToString(Convert.ToInt32(IrfTable_tc_ows.GetString("Posnr")));
                model.ZTSD001P_Lgort = IrfTable_tc_ows.GetString("Lgort");
                model.ZTSD001P_Pstyv = IrfTable_tc_ows.GetString("Pstyv");
                model.ZTSD001P_Matnr = IrfTable_tc_ows.GetString("Matnr");
                model.ZTSD001P_Vrkme = IrfTable_tc_ows.GetString("Vrkme");
                model.ZTSD001P_Kdmat = IrfTable_tc_ows.GetString("Kdmat");
                model.ZTSD001P_Charg = IrfTable_tc_ows.GetString("Charg");
                model.ZTSD001P_Inftid = IrfTable_tc_ows.GetString("Inftid");
              

                list.Add(model);
            }
            return list;
        }
        #endregion
        #region 回写SAP导入状态
        /// <summary>
        /// 转储订单
        /// </summary>
        public bool SavePomigoInfo(List<Model.SAPDataModel> lists)
        {
            /*    //导入SAP单头资料
                SAPDatas = new List<Model.SAPDataModel>();
                var KDara_w = SAPDatas.Select(m => m.ZTMM009K).ToList().Where(m => m.Ebeln == ebeln);
                var KDara_p = SAPDatas.Select(m => m.ZTMM009P).ToList().Where(m => m.Ebeln == ebeln);

                var KDara_w = lists.Select(m => m.ZTMM009K).ToList();
                //导入SAP单身资料
                var PDara_w = lists.Select(m => m.ZTMM009P).ToList();
                RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination("DEV");
                RfcRepository SapRfcRepository = SapRfcDestination.Repository;
                var list = new List<Model.SAPDataModel>();

                //转储订单
                IRfcFunction myfun = SapRfcRepository.CreateFunction("ZMMRFC_POMIGO");
                //传入结构INPUT  
                myfun.SetValue("ZPOINTF", "PSUB0" + zpointf);
                //myfun.SetValue("ZPOINTF", "PSUB01");
                myfun.SetValue("CALL_TYPE", "Q");
                myfun.Invoke(SapRfcDestination);
                IRfcTable IrfTable = myfun.GetTable("IT_ZTMM009K");
                IRfcTable IrfTable_tc_ows = myfun.GetTable("IT_ZTMM009P");
                */
            return true;
        }

        /// <summary>
        /// 预留凭证
        /// </summary>
        public bool SaveMsegExport(List<Model.SAPDataModel> lists)
        {
            var KDara_w = lists.Select(m => m.MSEG_EXPORT).ToList();
            //todo   把 KDara_w 的数据保存到SAP里面


            return true;
        }

        /// <summary>
        /// 物料凭证
        /// </summary>
        public bool SaveRkpfExport(List<Model.SAPDataModel> lists)
        {
            var KDara_w = lists.Select(m => m.PKPF_EXPORT).ToList();
            //todo   把 KDara_w 的数据保存到SAP里面


            return true;
        }

        /// <summary>
        /// 交货单
        /// </summary>
        public bool SaveDelivery(List<Model.SAPDataModel> lists)
        {
            //导入SAP单头资料
            var KDara_w = lists.Select(m => m.ZTSD001K).ToList();
            //导入SAP单身资料
            var PDara_w = lists.Select(m => m.ZTSD001P).ToList();
            //todo   把 KDara_w和PDara_w 的数据保存到SAP里面

            return true;
        }


        #endregion
    }
}
